$('#startWork').mouseover(function () {
    $(this).attr('class', 'item choose_bg')
})

$('#startWork').mouseout(function () {
    $(this).attr('class', 'item')
})

$('#stopWork').mouseover(function () {
    $(this).attr('class', 'item choose_bg')
})

$('#stopWork').mouseout(function () {
    $(this).attr('class', 'item')
})

$('#startWork').click(function () {
    var bg = chrome.extension.getBackgroundPage()
    bg.startWork()
    window.close()
})

$('#stopWork').click(function () {
    var bg = chrome.extension.getBackgroundPage()
    bg.stopWork()
    window.close()
})

// 向content-script主动发送消息
function sendMessageToContentScript(message, callback) {
    getCurrentTabId(function(tabId) {
        chrome.tabs.sendMessage(tabId, message, function (response) {
            if (callback) callback(response);
        });
    });
}

// 获取当前选项卡ID
function getCurrentTabId(callback) {
    chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
        console.log(tabs.length ? tabs[0].id : null);
    });
}

